/**
 * Captain
 * © 2018 Captain copyright，All rights reserved.
 * http://www.sccaptain.com.cn
 * 
 * JAVA : 8
 * 文  件  名: AdressController.java
 * 创  建  人: QinYoubin (qin.youbin@sccaptain.com.cn)
 * 创建时间: 2018年5月2日 下午1:13:41
 * 版         本: 1.0.0
 * 备         注:
 * 修订历史:
 */
package com.material.c2c.web.user.controller;

import javax.annotation.Resource;

import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import com.cpt.framework.web.JsonResult;
import com.material.c2c.user.entity.SHDZ;
import com.material.c2c.user.service.AdressService;
import com.material.c2c.web.util.ControllerUtil;

/**
 * 收货地址控制器
 * @since 1.0
 * @version 1.0
 * @author QinYoubin (qin.youbin@sccaptain.com.cn)
 */
@RestController
@RequestMapping("/address")
public class AdressController {
  @Resource
  private AdressService addressService;
  
  /**
   * 新增收货地址
   * @param shdz
   * @return
   * @since 1.0
   * @version 1.0
   * @author QinYoubin (qin.youbin@sccaptain.com.cn)
   */
  @PostMapping("/add")
  public JsonResult add(@RequestBody SHDZ shdz) {
    return ControllerUtil.getResult(addressService.add(shdz));
  }
  @GetMapping("/delete/{id}")
  public JsonResult delete(@PathVariable String id) {
    return ControllerUtil.getResult(addressService.delete(id));
  }
  @PostMapping("/update")
  public JsonResult update(@RequestBody SHDZ shdz) {
    return ControllerUtil.getResult(addressService.update(shdz));
  }
  @GetMapping("/listByUser/{id}")
  public JsonResult listByUser(@PathVariable String id) {
    return JsonResult.success(addressService.search(id));
  }
  @GetMapping("/getOne/{id}")
  public JsonResult getOne(@PathVariable String id) {
    return JsonResult.success(addressService.getOne(id));
  }
}
